import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: '首页',
    redirect: '/integral-shop'
  },
  {
    path: '/integral-shop',
    name: '积分商城',
    component: loadView('/integralShop/index.vue')
  },
  {
    path: '/integral-shop-detail',
    name: '积分商品详情',
    component: loadView('/integralShopDetail/index.vue')
  },
  {
    path: '/integralOrderComplete',
    name: '积分订单创建',
    component: loadView('/integralOrderComplete/index.vue')
  },
  {
    path: '/integralConfirmOrder',
    name: '积分订单确认',
    component: loadView('/integralConfirmOrder/index.vue')
  },
  {
    path: '/integralPaySucc',
    name: '积分支付成功',
    component: loadView('/integralPaySucc/index.vue')
  },
  {
    path: '/integralOrderDetail',
    name: '积分订单详情',
    component: loadView('/integralOrderDetail/index.vue')
  },
  {
    path: '/addNewAddress', // 添加收货地址
    name: 'addNewAddress',
    component: loadView('/addNewAddress/index.vue')
  },
  {
    path: '/shippingAddress', // 收货地址列表
    name: 'shippingAddress',
    component: loadView('/shippingAddress/index.vue')
  },
  {
    path: '/my',
    name: '我的',
    component: () => loadView('/my.vue')
  }
]
function loadView(file) {
  return process.env.NODE_ENV === 'development' ? require('@/views' + file).default : () => import('@/views' + file)
}
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
